<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>添加商品</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
</head>
<body>

<div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
	<div class="layui-form-item">
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">规格名称：</label>
			<div class="layui-input-inline">
				<input type="text" name="name" id="name" autocomplete="off" class="layui-input">
			</div>
		</div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width:70px;">规格简称：</label>
            <div class="layui-input-inline">
                <input type="text" name="nameSort" id="nameSort" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width:70px;">包装规格：</label>
            <div class="layui-input-inline">
                <input type="text" name="packSpec" id="packSpec" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width:70px;">规格单位：</label>
            <div class="layui-input-inline">
                <input type="text" name="goodsUnit" id="goodsUnit" autocomplete="off" class="layui-input">
            </div>
        </div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">规格编号：</label>
			<div class="layui-input-inline">
				<input type="text" name="code" id="code" autocomplete="off" class="layui-input">
			</div>
		</div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width:70px;">商品重量：</label>
            <div class="layui-input-inline">
                <input type="text" name="weight" id="weight" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width:70px;">是否上架：</label>
            <div class="layui-input-inline" style="width:190px;">
                <input type="checkbox" class="switch_checked" lay-filter="stateS" lay-skin="switch" lay-text="上架|下架" checked>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width:70px;">个人限量：</label>
            <div class="layui-input-inline">
                <input type="text" name="ulimit" id="ulimit" autocomplete="off" class="layui-input" value="0">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width:70px;">商品限量：</label>
            <div class="layui-input-inline">
                <input type="text" name="sumlimit" id="sumlimit" autocomplete="off" class="layui-input" value="0">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width:70px;">库 存 数：</label>
            <div class="layui-input-inline">
                <input type="text" name="inventory" id="inventory" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width:70px;">报 警 数：</label>
            <div class="layui-input-inline">
                <input type="text" name="alarm" id="alarm" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width:70px;">供 货 价：</label>
            <div class="layui-input-inline">
                <input type="text" name="supplierprice" id="supplierprice" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline" style="display: none;">
            <label class="layui-form-label" style="width:70px;">店主自返：</label>
            <div class="layui-input-inline" style="width:190px;">
                <input type="checkbox" class="switch_checked" lay-filter="activitySelfS" lay-skin="switch" lay-text="是|否" checked>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width:70px;">推荐ID：</label>
            <div class="layui-input-inline">
                <input type="text" name="shareIdNo" id="shareIdNo" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width:70px;">运 营 商：</label>
            <div class="layui-input-inline">
                <input type="text" name="operator" id="operator" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width:70px;">运 营 部：</label>
            <div class="layui-input-inline">
                <input type="text" name="operations" id="operations" autocomplete="off" class="layui-input">
            </div>
        </div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">规格主图：</label>
			<div class="layui-input-inline" style="width:1000px;">
								<div class="layui-upload">
                                    <button type="button" class="layui-btn" id="btnPic">规格主图</button>
                                    <input type="hidden" class="proImg" id="pic" name="pic" value=""/>
                                    <div class="layui-upload-list  one-img">
                                        <img class="layui-upload-img" id="demoPic" width="100px" height="100px">
                                        <p id="demoTextPic"></p>
                                    </div>
                                </div>

			</div>
		</div>
        <table class="layui-table">
            <thead>
            <tr>
                <th>商城价</th>
                <th>商品成本</th>
                <th>运营成本</th>
                <th>运营部</th>
                <th>运营商</th>
                <th>分享赠</th>
                <th>消费赠</th>
                <th>随机红包</th>
                <th>购物卷</th>
                <th>代金券</th>
                <th>一星</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td><input class="product-price" id="price" type="text" name="price" value=""></td>
                <td><input class="product-price" id="cost" type="text" name="cost" value=""></td>
                <td><input class="product-price" id="operat" type="text" name="operat" value=""></td>
                <td><input class="product-price" id="operationsPrice" type="text" name="operationsPrice" value=""></td>
                <td><input class="product-price" id="operatorPrice" type="text" name="operatorPrice" value=""></td>
                <td><input class="product-price" id="share" type="text" name="share" value=""></td>
                <td><input class="product-price" id="consumption" type="text" name="consumption" value=""></td>
                <td><input class="product-price" id="redEnvelope" type="text" name="redEnvelope" value=""></td>
                <td><input class="product-price" id="coupon" type="text" name="coupon" value=""></td>
                <td><input class="product-price" id="vouchers" type="text" name="vouchers" value=""></td>
                <td><input class="product-price" id="owner1" type="text" name="owner1" value=""></td>
            </tr>
            <thead>
            <tr>
                <th>二星</th>
                <th>三星</th>
                <th>诚信</th>
                <th>芦荟屋</th>
                <th>合开价</th>
                <th>合开优惠价</th>
                <th>合开限量</th>
                <th>预售价</th>
                <th>预售限量</th>
                <th>最小利润</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td><input class="product-price" id="owner2" type="text" name="owner2" value=""></td>
                <td><input class="product-price" id="owner3" type="text" name="owner3" value=""></td>
                <td><input class="product-price" id="owner4" type="text" name="owner4" value=""></td>
                <td><input class="product-price" id="aloeVeraShop" type="text" name="aloeVeraShop" value=""></td>
                <td><input class="product-price" id="CooperationPrice" type="text" name="CooperationPrice" value=""></td>
                <td><input class="product-price" id="PreferentialPrice" type="text" name="PreferentialPrice" value=""></td>
                <td><input class="product-price" id="PreferentialLimited" type="text" name="PreferentialLimited" value=""></td>
                <td><input class="product-price" id="bookingPrice" type="text" name="bookingPrice" value=""></td>
                <td><input class="product-price" id="bookingLimited" type="text" name="bookingLimited" value=""></td>
                <td id="min">0</td>
            </tr>
            </tbody>
            <thead>
            <tr>
                <th>返消费券</th>
                <th>返代金券</th>
                <th>商品推荐</th>
                <th>服务中心</th>
                <th>区域服务</th>
                <th>开店补贴</th>
                <th>市场支持</th>
                <th>分享诚信值</th>
                <th>分享旅游值</th>
                <th>消费诚信值</th>
                <th>消费旅游值</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td><input type="text" name="activityCommission" id="activityCommission" class="product-price"></td>
                <td><input type="text" name="ownerCommission" id="ownerCommission" class="product-price"></td>
                <td><input class="product-price" id="shareGoods" type="text" name="shareGoods" value=""></td>
                <td><input class="product-price" id="service" type="text" name="service" value=""></td>
                <td><input class="product-price" id="areaService" type="text" name="areaService" value=""></td>
                <td><input class="product-price" id="commission1" type="text" name="commission1" value=""></td>
                <td><input class="product-price" id="commission2" type="text" name="commission2" value=""></td>
                <td><input class="product-price" id="shareFaith" type="text" name="shareFaith" value=""></td>
                <td><input class="product-price" id="consumptionFaith" type="text" name="consumptionFaith" value=""></td>
                <td><input class="product-price" id="shareTourism" type="text" name="shareTourism" value=""></td>
                <td><input class="product-price" id="consumptionTourism" type="text" name="consumptionTourism" value=""></td>
            </tr>
            </tbody>
        </table>
        <div class="layui-form-item layui-hide">
            <input type="text" id="shareId" value="0">
            <input type="text" id="operatorId" value="0">
            <input type="text" id="activitySelf" value="1">
            <input type="text" id="state" value="1">
            <input type="button" lay-submit lay-filter="LAY-user-front-submit" id="LAY-user-back-submit" value="确认">
        </div>

  </div>
</div>
<style>
.product-price {
    width: 80px;
    height: 25px;
    border: none;
    padding: 0px;
    margin: 0px;
}
</style>

<script src="/layui/layui.js"></script>
<script src="/layui/jquery.min.js"></script>
<script>
    layui.config({
        base: '/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function(){
        var $ = layui.$
            ,form = layui.form ;

        form.on('switch(stateS)',function (data) {
            //开关是否开启，true或者false
            var checked = data.elem.checked;
            if(checked) {
                $("#state").val(1);
            }
            else
            {
                $("#state").val(0);
            }
        });

        form.on('switch(activitySelfS)',function (data) {
            //开关是否开启，true或者false
            var checked = data.elem.checked;
            if(checked) {
                $("#activitySelf").val(1);
            }
            else
            {
                $("#activitySelf").val(0);
            }
        });
    });

    layui.use('upload', function(){
        var $ = layui.jquery
            ,upload = layui.upload;

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#btnPic'
            ,url: '/UploadFile'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                // obj.preview(function(index, file, result){
                //     $('#demoPic').attr('src', result); //图片链接（base64）
                // });
            }
            ,done: function(res){
                //如果上传失败
                if(res.code > 0){
                    return layer.msg('上传失败:'+res.msg);
                }
                //上传成功
                if(res.code == 0){
                    $("#pic").val(res.fileName);
                    $('#demoPic').attr('src', res.fileName);
                    return layer.msg('上传成功');
                }
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoTextPic');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });

    });

    var operatorId=0;
    $("#operator").blur(function () {
        var urls="/user?url=User%2FgetUserAndNoInfo&userNo="+$("#operator").val();
        $.ajax({
            url: urls,
            type: "GET",
            async:false,
            dataType: "json", //指定服务器返回的数据类型
            success: function(result) {
                if(result.code=="000000"){
                    if(result.data!=null){
                        operatorId=result.data.id;
                        $("#operatorId").val(operatorId);
                    }else{
                        operatorId=0;
                        alert("编号不存在!!");
                        $("#operator").val("");
                        $("#operatorId").val(0);
                    }
                }
            }
        });
    });

    var shareId=0;
    $("#shareIdNo").blur(function () {
        var urls="/user?url=User%2FgetUserAndNoInfo&userNo="+$("#shareIdNo").val();
        $.ajax({
            url: urls,
            type: "GET",
            async:false,
            dataType: "json", //指定服务器返回的数据类型
            success: function(result) {
                if(result.code=="000000"){
                    if(result.data!=null){
                        shareId=result.data.id;
                        $("#shareId").val(shareId);
                    }else{
                        shareId=0;
                        alert("编号不存在!!");
                        $("#shareIdNo").val("");
                        $("#shareId").val(0);
                    }
                }
            }
        });
    });

</script>
</body>
</html>